unit cef_ref_print_handler;

{$mode objfpc}{$H+}

interface

uses
    cef3api, cef3intf, cef3types, cef3lib,
    cef_ref_base;

{$ifdef cef_trunk}
type

    { TCefPrintDialogCallbackRef }

    TCefPrintDialogCallbackRef = class(TCefBaseRef, ICefPrintDialogCallback)
    private
        function instance: PCefPrintDialogCallback; inline;
    protected
        procedure Cont(ASettings: PCefPrintSettings);
        procedure Cancel;
    public
        class function UnWrap(Data: Pointer): ICefPrintDialogCallback;
    end;

    { TCefPrintJobCallback }

    TCefPrintJobCallback = class(TCefBaseRef, ICefPrintJobCallback)
    private
        function instance: PCefPrintJobCallback; inline;
    protected
        procedure Cont;
    public
        class function UnWrap(Data: Pointer): ICefPrintJobCallback;
    end;

    { TCefPrintHandlerRef }

    TCefPrintHandlerRef = class(TCefBaseRef, ICefPrintHandler)
    private
        function instance: PCefPrintHandler; inline;
    protected
    public
        class function UnWrap(Data: Pointer): ICefPrintHandler;
    end;
{$endif cef_trunk}

implementation

{$ifdef cef_trunk}
{ TCefPrintHandlerRef }

function TCefPrintHandlerRef.instance: PCefPrintHandler;
begin
    Result := PCefPrintHandler(FData);
end;

class function TCefPrintHandlerRef.UnWrap(Data: Pointer): ICefPrintHandler;
begin
  if Data <> nil then
      Result := Create(Data) as ICefPrintHandler
  else
      Result := nil;
end;

{ TCefPrintJobCallback }

function TCefPrintJobCallback.instance: PCefPrintJobCallback;
begin
    Result := PCefPrintJobCallback(FData);
end;

procedure TCefPrintJobCallback.Cont;
begin
    instance^.cont(FData);
end;

class function TCefPrintJobCallback.UnWrap(Data: Pointer): ICefPrintJobCallback;
begin
  if Data <> nil then
      Result := Create(Data) as ICefPrintJobCallback
  else
      Result := nil;
end;

{ TCefPrintDialogCallbackRef }

function TCefPrintDialogCallbackRef.instance: PCefPrintDialogCallback;
begin
    Result := PCefPrintDialogCallback(FData);
end;

procedure TCefPrintDialogCallbackRef.Cont(ASettings: PCefPrintSettings);
begin
    instance^.cont(FData, ASettings);
end;

procedure TCefPrintDialogCallbackRef.Cancel;
begin
    instance^.cancel(FData);
end;

class function TCefPrintDialogCallbackRef.UnWrap(Data: Pointer): ICefPrintDialogCallback;
begin
  if Data <> nil then
      Result := Create(Data) as ICefPrintDialogCallback
  else
      Result := nil;
end;
{$endif cef_trunk}

end.


